<extend name="Public/layout"/>
<block name="head">
    <link rel="stylesheet" href="__PUBLIC__css/usercenter.css?A=<php>echo time()</php>">
    <script src="__PUBLIC__js/util.js"></script>

    <script>
        (function (window) {
            var docEl = document.documentElement;
            var h;

            function setUnitA() {
                window.rem = docEl.getBoundingClientRect().width / 10;
                docEl.style.fontSize = window.rem + 'px';
            }

            window.addEventListener('resize', function () {
                clearTimeout(h);
                h = setTimeout(function () {
                    setUnitA();
                }, 300);
            }, false);

            window.addEventListener('pageshow', function (e) {
                if (e.persisted) {
                    clearTimeout(h);
                    h = setTimeout(function () {
                        setUnitA();
                    }, 300);
                }
            }, false);

            setUnitA();

        })(window);
    </script>
</block>
<block name="main">
    <!--用户中心页头-->
    <!-- <div class="header">
        <div class="header-panel">
            <div class="header-panel-top">
                <div class="userinfo">
                    <div class="avatar" onclick="changeAvatar()">
                        <img id="uploadPreview" src="{$user_info.url_img}" alt="">
                        <input id="uploadImage" type="file" onchange="loadImageFile()">
                    </div>
                    <div class="info-wrapper">
                        <p class="name">{$user_info.nickname}</p>
                        <p class="user-number">{:hidtel($user_info[user_phone])}</p>
                    </div>
                </div>
                <div class="tool-box">
                    <div class="message" onclick="location.href='/Home/Person/notice'"></div>
                    <div class="setting" onclick="location.href='/Home/Person/setting'"></div>
                </div>
            </div>
            <div class="header-panel-bottom">
                <div class="total-return">
                    <p class="total-money">
                        <if condition="$count_fx gt 0">{$count_fx}
                            <else/>
                            0.00
                        </if>
                    </p>
                    <p>累计返现（元）</p>
                </div>
                <div class="yesterday-return">
                    <p class="yesterday-money">
                        <if condition="$today_fx_count gt 0">{$today_fx_count}
                            <else/>
                            0.00
                        </if>
                    </p>
                    <p>昨日返现（元）</p>
                </div>
            </div>
        </div>
    </div> -->
    <!--前往投顾中心按钮-->
    <!-- <div class="header-dropmenu">
        <div class="wrapper">
            <if condition="$user_info.role eq 2">
                <a href="{:U('Person/push_index')}">
                    <div class="usercenter-icon-pusher"></div>
                    <span>前往理财投顾中心</span>
                    <div class="arrow-wrapper">
                        <span class="arrow-right"></span>
                    </div>
                </a>
                <else/>
                <a href="{:U('Recommend/apply_pusher')}">
                    <div class="usercenter-icon-pusher"></div>
                    <span>申请成为投顾</span>
                    <div class="arrow-wrapper">
                        <span class="arrow-right"></span>
                    </div>
                </a>
            </if>
        </div>
    </div> -->
    <!--用户中心工具栏-->
    <!-- <div class="uc-tools">
        <ul class="uc-tools-wrapper">
            <li class="ul-tool">
                <notempty name="user_info.bank_card">
                    <a href="/Home/Person/cash/val/1">
                        <else/>
                        <a href="javascript:" onclick="no_bank_card()">
                </notempty>
                <span class="icon-get-cash"></span>
                <p>提现</p>
                </a>
            </li>
            <li class="ul-tool">
                <a href="/Home/Person/trade_details">
                    <span class="icon-trade-details"></span>
                    <p>交易明细</p>
                </a>
            </li>
            <li class="ul-tool">
                <if condition='$user_info.card_status eq 0'>
                    <a href="/Home/Person/relaname">
                        <else/>
                        <a href="javascript:" onclick="is_real()">
                </if>
                <span class="icon-verification"></span>
                <p>实名认证</p>
                </a>
            </li>

            <li class="ul-tool">
                <if condition="$user_info.card_status eq 1">

                    <if condition='$user_info.bank_card gt 0'>

                        <a href="/Home/Person/unbind_bank_card">
                            <else/>
                            <a href="/Home/Person/bind_bank_card">
                    </if>

                    <else/>
                    <a href="javascript:" onclick="no_idcard()">
                </if>

                <span class="icon-bankcard"></span>
                <p>银行卡</p>
                </a>
            </li>

            <li class="ul-tool">
                <if condition='$user_info.auto_cash eq 0'>
                    <a href="javascript:" onclick="openAutoGetCash()">
                        <span class="icon-auto-get-cash"></span>
                        <p>自动提现</p>
                    </a>
                    <else/>
                    <a href="javascript:" onclick="closeAutoGetCash()">
                        <span class="icon-auto-get-cash"></span>
                        <p>关闭自动提现</p>
                    </a>
                </if>
            </li>
        </ul>
    </div> -->
    <!--用户余额信息-->
    <!-- <div class="user-account">
        <ul class="user-account-wrapper">
            <li class="user-account-item">
                <span class="item-name">可提现余额</span>
                <div class="arrow-wrapper">
                    <span class="arrow-right"></span>
                </div>
                <span class="total-cash-money">{$user_info.balance}</span>
                <notempty name="user_info.bank_card">
                    <a href="/Home/Person/cash/val/1">
                        <else/>
                        <a href="javascript:" onclick="no_bank_card()">
                </notempty>
                </a>
            </li>
            <li class="user-account-item">
                <span class="item-name">平台投资总额</span>
                <span class="plat-invest-money"><if condition="$plat_count gt 0">{$plat_count}<else/>0.00</if></span>
            </li>
            <li class="user-account-item">
                <span class="item-name">首投返利总额</span>
                <span class="extra-money"> <if condition="$st_count gt 0">{$st_count}<else/>0.00</if></span>
            </li>
            <li class="user-account-item">
                <span class="item-name">加息返利总额</span>
                <span class="extra-money"> <if condition="$st_count gt 0">{$ft_count}<else/>0.00</if></span>
            </li>
        </ul>
    </div> -->
    <!-- 头部 -->
    <div class="news-header">
        <div class="list-item">
            <p>累计返现(元)</p>
            <p><if condition="$count_fx gt 0">{$count_fx}
                            <else/>
                            0.00
                        </if></p>
            <p>昨日返现<span>{$today_fx_count}</span>元</p>
        </div>
        <div class="list-item-info">
            <ul>
                <li>
                    <div class="list">
                        <dt><if condition="$plat_count gt 0">{$plat_count}<else/>0.00</if></dt>
                        <dd>平台投资总额</dd>
                    </div>
                </li>
                <li>
                    <div  class="list">
                        <dt><if condition="$st_count gt 0">{$st_count}<else/>0.00</if></dt>
                        <dd>首投返利总额</dd>
                    </div>                    
                </li>
                <li>
                    <div  class="list">
                        <dt><if condition="$st_count gt 0">{$ft_count}<else/>0.00</if></dt>
                        <dd>加息返利总额</dd>
                    </div>                    
                </li>
            </ul>
        </div>
    </div>
    <!--平台投资信息-->
    <div class="plat-invest">
        <div class="plat-invest-header">
            <h5>平台投资<span>每天将从平台同步一次投资明细</span></h5>
        </div>
        <ul class="plat-invest-content">
            <foreach name="platform_list" item="v">
                <li class="plat-invest-item">
                    <a href="/Home/Financial/event/id/{$v.id}/packet/{$_SESSION[user][id]}">
                        <div class="plat-logo">
                            <img src="{$v.pic}" alt="">
                        </div>
                        <div class="invest-money-wrapper">
                            <p class="invest-money"><em>{$v.plat_count}</em>元</p>
                            <p class="invest-money-name">投资总额</p>
                        </div>
                        <div class="return-money-wrapper">
                            <p class="return-money"><em>{$v.fl_count}</em>元</p>
                            <p class="invest-money-name">返利总额</p>
                        </div>
                        <div class="arrow-wrapper">
                            <span class="arrow-right"></span>
                        </div>
                    </a>
                </li>
            </foreach>
        </ul>
    </div>
<!-- 
        <if condition="!$recommend">
            <div class="aside" id="asideBar">
                <a href="{:U('Recommend/apply_pusher_form')}">
                    <span class="icon-become-pusher"></span>
                    <span class="text">成为投顾</span>
                </a>
            </div>
        <else/>
            
            <div class="aside" id="asideBar">
                <a href="{:U('Person/push_index')}">
                    <span class="pushercenter"></span>
                    <span class="text">投顾账户</span>
                </a>
            </div>
        </if> -->
</block>
<block name="js">
    <script type="text/javascript">
        $(function () {
            $(window).bind("scrollstart", function () {
                $("#asideBar").css("transform", "translate3d(100%, 0, 0)")
            })

            $(window).bind("scrollstop", function () {
                $("#asideBar").css("transform", "translate3d(0, 0, 0)")
            })
        })

        function no_idcard() {
            layer.open({
                content: "您还未实名验证！"
                , btn: ['前往', '取消']
                , yes: function (index) {
                    console.log(1);
                    location.href = "/Home/Person/relaname"
                }
            });
        }

        function no_bank_card() {
            layer.open({
                content: "您还未绑定银行卡,请先绑定银行卡！"
                , btn: ['前往', '取消']
                , yes: function (index) {
                    location.href = "/Home/Person/bind_bank_card"
                }
            });
        }

        function is_real() {
            layer.open({
                content: "您已经实名验证！"
                , skin: 'msg'
                , time: 1 //2秒后自动关闭
            });
        }


        function openAutoGetCash() {
            // 开启自动提现弹框
            var h = '';
            h += '<div class="get-cash-layer">'
            h += '<div class="content-wrapper"><h3>开启自动提现</h3>'
            h += '<p class="text">开启自动提现后</p>'
            h += '<p class="text">每天17点将会自动将您账户</p>'
            h += '<p class="text">可提现余额提现到您绑定银行卡哦</p></div>'
//        h += '<div class="btn-wrapper"><a href="#">我不需要</a>'
//        h += '<a href="#">确认开启</a></div>'
            h += '</div>'

            layer.open({
                type: 1
                , content: h
                , btn: ['确认', '取消']
                , yes: function (index) {
                    auto_cash(1);
                }
            });
        }

        function closeAutoGetCash() {
            // 开启自动提现弹框
            var h = '';
            h += '<div class="get-cash-layer">'
            h += '<div class="content-wrapper"><h3>关闭自动提现</h3>'
            h += '<p class="text">关闭自动提现后</p>'
            h += '<p class="text">余额将不会每天自动提现</p>'
            h += '</div>'

            layer.open({
                type: 1
                , content: h
                , btn: ['确认', '取消']
                , yes: function (index) {
                    auto_cash(0);
                }
            });
        }

        function auto_cash(auto) {
            $.post('{:U("Person/auto_cash")}', {
                auto: auto,
            }, function (res) {
                if (res.err == 2) {
                    layer.closeAll()
                    layer.open({
                        content: "您还未绑定银行卡,请先绑定银行卡！"
                        , btn: ['前往', '取消']
                        , yes: function (index) {
                            location.href = "/Home/Person/bind_bank_card"
                        }
                    });
                } else {
                    layer.open({
                        content: res.msg
                        , skin: 'msg'
                        , time: 1
                        , end: function () {
                            location.reload()
                        }
                    });
                }
            })
        }


        var oFReader = new FileReader();
        var rFilter = /^(?:image\/bmp|image\/cis\-cod|image\/gif|image\/ief|image\/jpeg|image\/jpeg|image\/jpeg|image\/pipeg|image\/png|image\/svg\+xml|image\/tiff|image\/x\-cmu\-raster|image\/x\-cmx|image\/x\-icon|image\/x\-portable\-anymap|image\/x\-portable\-bitmap|image\/x\-portable\-graymap|image\/x\-portable\-pixmap|image\/x\-rgb|image\/x\-xbitmap|image\/x\-xpixmap|image\/x\-xwindowdump)$/i;

        oFReader.onload = function (oFREvent) {
            document.getElementById("uploadPreview").src = oFREvent.target.result;
        };

        function loadImageFile() {
            if (document.getElementById("uploadImage").files.length === 0) {
                return;
            }
            var oFile = document.getElementById("uploadImage").files[0];
            if (!rFilter.test(oFile.type)) {
                alert("You must select a valid image file!");
                return;
            }
            oFReader.readAsDataURL(oFile);
        }

        //    修改头像功能
        var oFReader = new FileReader();
        var rFilter = /^(?:image\/bmp|image\/cis\-cod|image\/gif|image\/ief|image\/jpeg|image\/jpeg|image\/jpeg|image\/pipeg|image\/png|image\/svg\+xml|image\/tiff|image\/x\-cmu\-raster|image\/x\-cmx|image\/x\-icon|image\/x\-portable\-anymap|image\/x\-portable\-bitmap|image\/x\-portable\-graymap|image\/x\-portable\-pixmap|image\/x\-rgb|image\/x\-xbitmap|image\/x\-xpixmap|image\/x\-xwindowdump)$/i;

        oFReader.onload = function (oFREvent) {
            document.getElementById("uploadPreview").src = oFREvent.target.result;
            $.post('/Home/Person/change_head_pic',{
                file:oFREvent.target.result
            },function(res){
                if(res.errorCode==1) {
                    layer.open({
                        content: res.msg
                        , skin: 'msg'
                        , time: 1
                    });
                }
            })
        };

        function loadImageFile() {
            if (document.getElementById("uploadImage").files.length === 0) { return; }
            var oFile = document.getElementById("uploadImage").files[0];
            if (!rFilter.test(oFile.type)) { alert("You must select a valid image file!"); return; }
            oFReader.readAsDataURL(oFile);
        }

        function changeAvatar() {

//        底部对话框
            layer.open({
                content: ''
                ,className: 'avatar-layer'
                ,btn: ['取消', '从相册选择']
                ,skin: 'footer'
                ,no: function () {
                    $('#uploadImage').click()
                    layer.closeAll()
                }
                ,yes: function(index){
                    layer.close(index);
                }
            });
        }




    </script>
</block>